<template>
  <div class="login-container">
    <a-card class="login-card">
      <div class="header">
        <div class="title-container">
          <img src="@/assets/dog.svg" alt="AI面试官" class="logo" />
          <h1>AI Java 面试官</h1>
        </div>
        <p>准备好开始你的技术面试了吗？</p>
      </div>
      <LoginForm @login="handleLogin" />
    </a-card>
  </div>
</template>

<script setup>
import { message } from 'ant-design-vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/authStore'
import LoginForm from '@/components/LoginForm.vue'

const router = useRouter()
const authStore = useAuthStore()

const handleLogin = async (credentials) => {
  try {
    await authStore.login(credentials)
    message.success('登录成功')
    router.push('/chat')
  } catch (error) {
    message.error(error.message || '登录失败')
  }
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f0f2f5;
}

.login-card {
  width: 400px;
  text-align: center;
}

.header {
  margin-bottom: 24px;
}

/* 新增logo样式 */
.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo {
  width: 40px;
  height: 40px;
}

/* 调整标题样式 */
.header h1 {
  color: #1890ff;
  margin: 0; /* 移除原有下边距 */
}

.header p {
  margin-top: 8px;
  color: #666;
}
</style>
